package com.atguigu.spzx.user.controller;

import com.atguigu.spzx.model.entity.h5.Region;
import com.atguigu.spzx.model.result.Result;
import com.atguigu.spzx.user.service.RegionService;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/user/region")
@Tag(name = "地区信息模块")
public class RegionController {
    @Resource
    RegionService regionService;
    @Operation(summary = "根据parentCode查询下一级区域信息列表")
    @GetMapping("/findByParentCode/{parentCode}")
    public Result findByParentCode(@PathVariable("parentCode")Long parentCode){
        List<Region> regions = regionService.list(Wrappers.lambdaQuery(Region.class)
                .eq(Region::getParentCode, parentCode));
        return Result.ok(regions);
    }

}
